#include "process.h"
#include <string.h>
#include <unistd.h>

#define NUM 101
#define STYLE '='

//vesion2
void FlushProcess(double total,double current)
{
	char buffer[NUM];
	memset(buffer,0,sizeof(buffer));
	const char* lable = "|/-\\";
	int len = strlen(lable);

	static int cnt = 0;
	
	//不需自己循环
	int num = (int)(current*100/total); // 11.0/1000
	int i = 0;
	for (; i < num; i++)
	{
		buffer[i] = STYLE;
	}
	double rate = current/total;
	cnt %= len;
	printf("[%-100s][%.1f%%][%c]\r",buffer,rate*100,lable[cnt]);
	cnt++;
	fflush(stdout);
}


